package cn.iocoder.yudao.module.enterprise.dal.mysql.enterpriseJob;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.enterprise.controller.admin.enterpriseJob.vo.EnterpriseJobCensusRespVO;
import cn.iocoder.yudao.module.enterprise.controller.admin.enterpriseJob.vo.EnterpriseJobExportReqVO;
import cn.iocoder.yudao.module.enterprise.controller.admin.enterpriseJob.vo.EnterpriseJobPageReqVO;
import cn.iocoder.yudao.module.enterprise.controller.admin.enterpriseJob.vo.EnterpriseJobViewCountVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.enterpriseJob.EnterpriseJobDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 招聘职位 Mapper
 *
 * @author 谭万全
 */
@Mapper
public interface enterpriseJobMapper extends BaseMapperX<EnterpriseJobDO> {

    default PageResult<EnterpriseJobDO> selectPage(EnterpriseJobPageReqVO reqVO) {
        return pageQuery(reqVO, new LambdaQueryWrapperX<EnterpriseJobDO>()
                .likeIfPresent(EnterpriseJobDO::getCompanyName, reqVO.getCompanyName())
                .likeIfPresent(EnterpriseJobDO::getIndustry, reqVO.getIndustry())
                .likeIfPresent(EnterpriseJobDO::getCity, reqVO.getCity())
                .likeIfPresent(EnterpriseJobDO::getJobName, reqVO.getJobName())
                .likeIfPresent(EnterpriseJobDO::getEducation, reqVO.getEducation())
                .inIfPresent(EnterpriseJobDO::getStatus, reqVO.getStatus())
                .likeIfPresent(EnterpriseJobDO::getTopStatus, reqVO.getTopStatus())
                .betweenIfPresent(EnterpriseJobDO::getPublishTime, reqVO.getBeginPublishTime(), reqVO.getEndPublishTime())
        );
    }

    default PageResult<EnterpriseJobDO> selectPage(EnterpriseJobPageReqVO reqVO,List<String> list) {
        return pageQuery(reqVO, new LambdaQueryWrapperX<EnterpriseJobDO>()
                .likeIfPresent(EnterpriseJobDO::getCompanyName, reqVO.getCompanyName())
                .likeIfPresent(EnterpriseJobDO::getIndustry, reqVO.getIndustry())
                .likeIfPresent(EnterpriseJobDO::getCity, reqVO.getCity())
                .likeIfPresent(EnterpriseJobDO::getJobName, reqVO.getJobName())
                .likeIfPresent(EnterpriseJobDO::getEducation, reqVO.getEducation())
                .inIfPresent(EnterpriseJobDO::getStatus, list)
                .likeIfPresent(EnterpriseJobDO::getTopStatus, reqVO.getTopStatus())
                .betweenIfPresent(EnterpriseJobDO::getPublishTime, reqVO.getBeginPublishTime(), reqVO.getEndPublishTime())
        );
    }

    default PageResult<EnterpriseJobDO> getJobWaitExaminePage(EnterpriseJobPageReqVO reqVO, List<String> flag) {
        return pageQuery(reqVO, new LambdaQueryWrapperX<EnterpriseJobDO>()
                .likeIfPresent(EnterpriseJobDO::getCompanyName, reqVO.getCompanyName())
                .likeIfPresent(EnterpriseJobDO::getJobName, reqVO.getJobName())
                .likeIfPresent(EnterpriseJobDO::getDepartment, reqVO.getDepartment())
                .likeIfPresent(EnterpriseJobDO::getPhone, reqVO.getPhone())
                .likeIfPresent(EnterpriseJobDO::getEmail, reqVO.getEmail())
                .inIfPresent(EnterpriseJobDO::getStatus, flag)
                .likeIfPresent(EnterpriseJobDO::getCreator, reqVO.getCreator())
                .likeIfPresent(EnterpriseJobDO::getOperation,reqVO.getOperation())
                .likeIfPresent(EnterpriseJobDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(EnterpriseJobDO::getCreateTime, reqVO.getCreateStarDate(), reqVO.getCreateEndDate())
        );

    }
    List<EnterpriseJobDO> recoveryEnterpriseJobPage(IPage page, @Param("request") Map<String, Object> request );

    void updateBatchRecoveryEnterpriseJob(@Param("ids") List<Long> ids);
    void updateEnterpriseJobFixed( @Param("id") Long id,@Param("timingStatus") Integer timingStatus,@Param("fixedTime") String fixedTime );

    default List<EnterpriseJobDO> selectList(EnterpriseJobExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EnterpriseJobDO>()
                .likeIfPresent(EnterpriseJobDO::getCompanyName, reqVO.getCompanyName())
                .likeIfPresent(EnterpriseJobDO::getJobName, reqVO.getJobName())
                .eqIfPresent(EnterpriseJobDO::getStatus, reqVO.getStatus())
                .orderBy(EnterpriseJobDO.class, PageParam.DEFAULT_SORTING_FIELDS));
    }
    Integer getResumeCount(@Param("jobId") Long jobId);

    EnterpriseJobCensusRespVO getEnterpriseJobCensus(@Param("param") Map<String,Object> param);

    List<String> getEnterpriseJobLastDay(@Param("companyId") Long companyId,@Param("list") List<String> list);

    @TenantIgnore
    List<EnterpriseJobViewCountVO> getEnterpriseJobViewCount(@Param("jobId") Long jobId,@Param("startDate") String startDate);
    @TenantIgnore
    List<EnterpriseJobViewCountVO> getEnterpriseVitaeSendRecordCount(@Param("jobId") Long jobId,@Param("startDate") String startDate);
    @TenantIgnore
    EnterpriseJobCensusRespVO getVitaeSendRecordCensus(@Param("param") Map<String,Object> param);
}
